<?php
namespace app\common\model;
use think\Model;
use think\facade\Db;
use think\model\concern\SoftDelete;

class Shop extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    protected $autoWriteTimestamp = true;
    
    public function taocan()
    {
        return $this->belongsTo(Taocan::class, 'taocan', 'id')->bind(['taocan_name'=>'name']);
    }
    public function getExpTimeAttr($value)
    {
        return date('Y-m-d',$value);
    }
    
    public function setExpTimeAttr($value)
    {
        return strtotime($value);
    }
    //关联删除
    public static function Delall($shop_id) {
        Db::table('hq_finance')->where('shop_id',$shop_id)->delete();
        Db::table('hq_shop_config')->where('shop_id',$shop_id)->delete();
        Db::table('hq_shop_order')->where('shop_id',$shop_id)->delete();
        Db::table('hq_user_group')->where('shop_id',$shop_id)->delete();
        Db::table('hq_user_code')->where('shop_id',$shop_id)->delete();
        Db::table('hq_user_log')->where('shop_id',$shop_id)->delete();
        return;
    }
    
    
    
    
}